#include <bits/stdc++.h>

using namespace std;

#define N 105

struct node{
    int id, nextid;
    int data;
}node[N];

int main(){
    int n, m;
    cin >> n >> m;
 
    node[0].id = 0;
    for (int i = 1; i <= n; i++){
        node[i].id = i;
        node[i].nextid = i + 1;       
    }
    node[n].nextid = 1;

    int now = 1, prev = n;
    while ((n--) > 1){
        for (int i = 1; i < m; i++){
            prev = now;
            now = node[now].nextid;
        }
        cout << node[now].id << " ";
        node[prev].nextid = node[now].nextid;
        now = node[prev].nextid;
    }
    cout << node[now].id;

    return 0;
}